<template>
  <div class="box">
    <div class="top">
      <h3>新用户注册</h3>
      <p>很高兴你将成为商城的会员(注册只需一步)</p>
    </div>
    <div class="center">
      <van-form @submit="onSubmit">
        <van-field
          v-model="phone"
          name="手机号码"
          label="手机号码"
          placeholder="请输入手机号码"
          :rules="[{ pattern:/^1[3|4|5|7|8][0-9]{9}$/, message: '请输入正确的手机号' }]"
        />
        <van-field
          v-model="password"
          type="password"
          name="密码"
          label="密码"
          placeholder="密码"
          :rules="[{ validator, message: '请输入正确的密码' }]"
        />
        <van-field
          v-model="pass"
          type="password"
          name="密码"
          label="确认密码"
          placeholder="确认密码"
          :rules="[{ validator, message: '请输入正确的密码' }]"
        />
        <van-field
          v-model="username"
          name="手机号码"
          label="用户名"
          placeholder="用户名"
          :rules="[{ pattern:/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$/, message: '请输入正确的名字' }]"
        />
        <div style="margin: 16px;">
          <van-button round block type="info" native-type="submit">立即注册</van-button>
        </div>
      </van-form>
    </div>
    <!-- <van-area title="标题" :area-list="areaList" value="110101" /> -->
    <div class="bottom">
      <router-link to="/login">已有账号?立即登录</router-link>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      phone: "",
      password: "",
      pass: "",
      username: "",
    };
  },
  methods: {
    onSubmit(values) {
      console.log("submit", values);
    },
    validator(val) {
      return /^[a-zA-Z_][a-zA-Z0-9]{4,19}/.test(val);
    },
    reset() {
      this.$router.push("/reset");
    },
  },
};
</script>

<style scoped>
.bottom {
  width: 100%;
  /* height: 6.5rem; */
  text-align: center;
}
.box {
  width: 95%;
  height: 95%;
  border: 1px solid #eee;
  margin: 2.5% auto;
}

.top h3 {
  font-size: 0.4rem;
  color: gray;
  margin: 0.8rem 0.5rem 0 0.5rem;
}
.top p {
  color: gray;
  margin: 0.4rem 0.5rem;
}
</style>